#!/usr/bin/python
# -*- coding: UTF-8 -*-

"""
@author: jiu
@contact: 643562684@qq.com
@time: 2022/3/10 14:05
"""

import unittest
from os.path import join

from unittestreport import TestRunner

from common.create_data import dt
from common.read_Ini import Read_InI
from Conf.setting import (PROJECT_CONF_SETTING, UNITTEST_REPORT_PATH,
                          UNITTEST_TEST_PATH)

if __name__ == '__main__':
    suit = unittest.defaultTestLoader.discover(UNITTEST_TEST_PATH)
    report_path = join(UNITTEST_REPORT_PATH, dt.now_data)
    runn = TestRunner(suit, report_dir=report_path, tester='zml', templates=2)
    runn.run()

    _ini = Read_InI(PROJECT_CONF_SETTING["project"]).data['email']
    runn.send_email(host=_ini["host"],
                    port=_ini["port"],
                    user=_ini["user"],
                    password=_ini["password"],
                    to_addrs='',
                    is_file=True)
